package main

import (
	"fmt"
	"gopkg.in/redis.v2"
)

var (
	redisAddr   = "127.0.0.1:6379"
	redisPasswd = ""
)
var redisClient *redis.Client

func main() {
	redisClient = redis.NewTCPClient(&redis.Options{
		Addr:     redisAddr,
		PoolSize: 100,
		Password: redisPasswd,
	})
	defer redisClient.Close()

	_, err := redisClient.HMSet("uid001", "name", "bob", "age", "24", "sex", "male").Result()
	if nil != err {
		fmt.Println("insert fail")
		return
	}
	name := redisClient.HGet("uid001", "name").String()
	fmt.Println(name)
	testmap, err := redisClient.HGetAllMap("uid001").Result()
	fmt.Println(testmap["name"])
	_, err = redisClient.HDel("uid001", "name").Result()
	if nil != err {
		fmt.Println("remove name fail")
		return
	}
	all, _ := redisClient.HGetAllMap("uid001").Result()
	fmt.Println(all)

}
